#include "department.h"
#include "employee.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include "servicedao_file_impl.h"

using namespace std;
using namespace MH;

//ServiceDaoFileImpl::ServiceDaoFileImpl(void)
//{
//}

Department::Department(int id,const char* strName)
{
	m_strName=strName;
	m_nid =	id;
	
}

void Department::addEmp(void)
{
	char name[20]={};
	cout << "请输入姓名：";
	cin >> name;
	bool sex = true;
	cout << "请输入性别：";
	cin >> sex;
	int age = 0;
	cout << "请输入年龄：";
	scanf("%d",&age);
	cout << endl;
	int id = 10;
	Employee* en = new Employee(id,name,sex,age);
	m_vecEmps.push_back(*en);
	cout << "恭喜：" << name << "加入" << m_nid << "号部门" 
		<< endl;
	sleep(2);

}

bool Department::deleteEmp(void)
{
	cout << "输入要删除的员工id：" << endl;
	int id = 0;
	cin >> id;
	for(unsigned int i=0;i<m_vecEmps.size();i++)
	{
		if(m_vecEmps[i].getid() == id)
		{
		//	m_employee.set_employee(0,"noman",true,0);
			m_vecEmps.erase(m_vecEmps.begin()+i);  

			return true;
		}
	}
	return false;
}

bool Department::modifyEmp(void)
{
	cout << "输入要删除的员工id：" << endl;
	int id = 0;
	cin >> id;
	for(unsigned int i=0;i<m_vecEmps.size();i++)
	{
		if(m_vecEmps[i].getid() == id)
		{
			int ch_age = 0;
			cout << "请输入要修改的年龄:" << endl;
			cin >> ch_age;
			m_vecEmps[i].m_nAge = ch_age;
			return true;
		}
	}
	return false;
	
}

void Department::listEmp(void)
{
	cout << "工号" << " " << "姓名" << " " << "性别" << " " << "年龄" << endl;

	for(unsigned int i=0; i<m_vecEmps.size(); i++)
	{
		m_vecEmps[i].get_employee();
	}
	sleep(2);
}
